﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace PWAsker
{
    //An Action holds Executables
    public class Action
    {
        //serialized objects + setter/getter
        private String _ActionName;
        public String ActionName
        {
            get { return _ActionName; }
            set { _ActionName = value; }
        }
        
        private List<Executable> _lExecutables = new List<Executable>();
        public List<Executable> lExecutables
        {
            get { return _lExecutables; }
            set { _lExecutables = value; }
        }

        //default constuctor
        public Action()
        {
            Debug.WriteLine("New action-object generated. Dump: " + _ActionName + " ~ Listsize: " + _lExecutables.Count);
        }

        //parametrized constuctor
        public Action(String szActionName)
        {
            _ActionName = szActionName;
            Debug.WriteLine("New action-object generated. Dump: " + _ActionName + " ~ Listsize: " + _lExecutables.Count);
        }

        //adds an executable to the active Action
        public void add(Executable objExecutable)
        {
            //Debug.WriteLine("Adding executable " + objExecutable.ExecCommand + " to Action " + _ActionName);
            lExecutables.Add(objExecutable);
        }

        //deletes all executables of the active Action
        public void clear()
        {
            Debug.WriteLine("Clearing all executables from Action " + _ActionName);
            lExecutables.Clear();
        }

        //returns all executables as String
        public List<String> getCurrentCommands()
        {
            List<String> lSzExecutables = new List<String>();

            foreach (Executable objExecutable in _lExecutables)
            {
                lSzExecutables.Add(objExecutable.ExecCommand);
            }

            return lSzExecutables;
        }

        //returns all executables as Executable
        public List<Executable> getCurrentExecutables()
        {
            return _lExecutables;
        }
    }
}
